﻿<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>公司信息</title>
    <link rel="stylesheet" type="text/css" href="../Content/Css/OperaMasksUI/default/om-all.css" />
    <link rel="stylesheet" type="text/css" href="../Content/Css/list.css" />
    <script type="text/javascript" src="../Scripts/jquery.1.6.3.min.js"></script>
    <script type="text/javascript" src="../Scripts/json2.js"></script>
    <script type="text/javascript" src="../Scripts/common.js"></script>
    <script type="text/javascript" src="../Scripts/OperaMasksUI/operamasks-ui.min.js"></script>
    <script type="text/javascript" src="../Scripts/Plugin/jquery.form.js"></script>
    <script type="text/javascript" src="../Scripts/OperaMasksUI/Plugin/om-yj-container.js"></script>
    <script type="text/javascript" src="../Scripts/Plugin/artDialog4.1.7/jquery.artDialog.js?skin=default"></script>
    <script type="text/javascript" src="../Scripts/Plugin/artDialog4.1.7/plugins/iframeTools.js"></script>
    <!--添加jquery easy ui 控件 begin-->
    <script type="text/javascript" src="../Scripts/jquery.easyui.min.js"></script>
    <link rel="stylesheet" type="text/css" href="../Scripts/themes/default/easyui.css">
	<link rel="stylesheet" type="text/css" href="../Scripts/themes/icon.css">
    <!--添加jquery easy ui 控件 end-->

    <script type="text/javascript">
        var detailPanel, listGrid, colData, searchPanel, defaultSort, defaultWhere, validatorForm, submitForm, currentUID, currentGIndex = -1, genRenderCheckbox, genRenderDateformat;
        var showSearchPanel, showToolBar, showDetialForm, controlBtn, oldRowData, detailForm, goOn = true, DoFlag = true, ifh;
        var actionRoot = "../handler/ajax.ashx?type=AjaxSystem", comboxBankData = [], comboxTypeData = [], comboxStatusData = [], genRenderDateformat, genRenderDateformatSS;

        $(document).ready(function () {
            var element = $('body').omBorderLayout({
                fit: true,
                spacing: 0,
                panels: [
                {
                    id: "center-panel",
                    header: true,
                    title: '<span style="color:#15428B;font-weight: bold;padding:6px;">基础数据列表</span><span id="button-edit" style="float:right;text-align:center;cursor:pointer;"><img src="../Content/Images/List/edit.png" width="16" height="16" style="border:none;vertical-align:middle" />编辑',
                    region: "center"
                }, {
                    id: "west-panel",
                    resizable: true,
                    collapsible: true,
                    title: "<span style='color:#15428B;font-weight: bold;padding:6px;'>查询条件</span>",
                    region: "west",
                    width: 230
                },
                {
                    id: "south-panel",
                    region: "south",
                    header: false,
                    resizable: false,
                    collapsible: false,
                    height: 50
                }
                ]
            });
            showSearchPanel();
            //Grid Column 
            colData = [
                { header: '公司编码', name: 'Code', width: 50, align: 'center' },
                { header: '公司简称', name: 'Short', width: 80, align: 'left' },
                { header: '中文名称', name: 'ChnName', width: 250, align: 'left' },
                { header: '英文名称', name: 'EngName', width: 200, align: 'center' },
                { header: '中文地址', name: 'ChnAddr', width: 200, align: 'center' },
                { header: '英文地址', name: 'EngAddr', width: 200, align: 'center' },
                { header: '银行CNY', name: 'ChnBank', width: 60, align: 'center' },
                { header: '账号CNY', name: 'ChnAccountNo', width: 60, align: 'center' },
                { header: '银行USD', name: 'EngBank', width: 60, align: 'center' },
                { header: '账号USD', name: 'EngAccountNo', width: 60, align: 'center' },
                { header: '营业执照号', name: 'BusNo', width: 60, align: 'center' },
                { header: '纳税编号', name: 'TaxNo', width: 120, align: 'center' },
                { header: '传真', name: 'FAX', width: 60, align: 'center' },
                { header: '邮件', name: 'EML', width: 60, align: 'center' },
                { header: '主页', name: 'IDX', width: 60, align: 'center' },
                { header: '账期', name: 'Period', width: 60, align: 'right' },
                { header: '备注', name: 'Note', width: 120, align: 'center' },
                { header: '创建人', name: 'UserCreate', width: 100, align: 'center' },
                { header: '创建时间', name: 'CreateDate', width: 120, align: 'center', renderer: genRenderDateformat },
                { header: '修改人', name: 'UserModify', width: 100, align: 'center' },
                { header: '修改时间', name: 'ModifyDate', width: 130, align: 'center',renderer: genRenderDateformat}
            ];
            //排序
            defaultSort = { sortby: 'Code', sortdir: 'DESC' };
            //条件
            defaultWhere = { where: ' 1=1 ' };
            //初始化
            listGrid = $('#listgrid').omGrid({
                width: '100%',
                height: 'fit',
                //autoFit: true,
                //title: '公司列表',
                singleSelect: true,
                limit: 20,
                extraData: $.extend(defaultWhere, defaultSort),
                dataSource: "{rows:[],total:0}",
                colModel: colData
            });
            showToolBar();
        });

        genRenderCheckbox = function (colValue, rowData, rowIndex) {
            if (colValue) {
                return '<input type="checkbox" id="00" checked="checked" disabled="disabled"></input>';
            }
            return '<input type="checkbox" id="01" disabled="disabled"></input>';
        }

        genRenderDateformatSS = function (colValue, rowData, rowIndex) {
            if (colValue.length == 0 || colValue == null) {
                return '';
            }
            else {
                if (colValue.indexOf("/Date") > -1)
                    return new Date(parseInt(colValue.replace("/Date(", "").replace(")/", ""), 10)).Format("yyyy-MM-dd");
                else
                    return colValue;
            }
        }

        genRenderDateformat = function (colValue, rowData, rowIndex) {
            if (colValue.length == 0 || colValue == null) {
                return '';
            }
            else {
                if (colValue.indexOf("/Date") > -1)
                    return new Date(parseInt(colValue.replace("/Date(", "").replace(")/", ""), 10)).Format("yyyy-MM-dd hh:mm");
                else
                    return colValue;
            }
        }

        showToolBar = function () {
            $('span#button-edit').click(function () {
                if (listGrid[0].rows.length > 0) {
                    var selectRow = listGrid.omGrid("getSelections", true);
                    var selectRowIndex = listGrid.omGrid("getSelections");
                    if (selectRow.length == 1 && selectRowIndex.length == 1) {
                        art.dialog.data('currentUID', currentUID);
                        art.dialog.data('RowData', selectRow[0]);
                        art.dialog.data('Mode', 'update');
                        art.dialog.open('BaseDataRegister.aspx', {
                            id: 'CompanyUpdate', width: 500, height: 250, title: '公司数据编辑', lock: true,
                            close: function () {
                            }
                        }, true);
                    }
                    else {
                        $.omMessageBox.alert({
                            content: '至少选取一条可编辑的数据'
                        });
                    }
                }
                else {
                    $.omMessageBox.alert({
                        content: '没有可编辑的数据'
                    });
                }
            });
        }

        //查询语句
        showSearchPanel = function () {
            $("#CreateDateStart").omCalendar();
            $("#CreateDateEnd").omCalendar();
            $("#button-search").click(function () {
                var custWhere = '';
//                修改日期控件 begin  
//                if ($("#search-panel input[id='CreateDateStart']").val().length > 0) {
//                    custWhere = " AND (CreateDate BETWEEN '" + $("#search-panel input[id='CreateDateStart']").val() + "' AND ";
//                    if ($("#search-panel input[id='CreateDateEnd']").val().length > 0) {
//                        custWhere += " '" + $("#search-panel input[id='CreateDateEnd']").val() + "') "
//                    }
//                    else {
//                        custWhere += " GETDATE()) "
//                    }
//                }
//                修改日期控件 end  

//                修改日期控件，新加方法 begin   
                if ($("#search-panel input[id='CreateDateStart']").combobox("getValue").length > 0) {
                    custWhere = " AND (CreateDate BETWEEN '" + $("#search-panel input[id='CreateDateStart']").combobox("getValue") + "' AND ";
                    if ($("#search-panel input[id='CreateDateEnd']").combobox("getValue").length > 0) {
                        custWhere += " '" + $("#search-panel input[id='CreateDateEnd']").combobox("getValue") + "') "
                    }
                    else {
                        custWhere += " GETDATE()) "
                    }
                }
//              修改日期控件，新加方法 end

                custWhere += ' AND Code LIKE ' + '\'%' + $("#search-panel input[id='Code']").val() + '%\'';
                custWhere += ' AND Short LIKE ' + '\'%' + $("#search-panel input[id='Short']").val() + '%\'';
                listGrid.omGrid({
                    extraData: $.extend({ where: defaultWhere.where + custWhere }, defaultSort),
                    dataSource: '../Handler/grid.ashx?view=vCompany'
                });
                //listGrid.omGrid('setSelections', [0]);
            });
            $('#button-clear').click(function () {
                $("div[id='search-panel'] input").val("");
            });
        };



 

    </script>
</head>
<body>
    <div id="west-panel" class="westpanel">
        <div id="search-panel">
            <table>
                <tr>
                    <td style="width: 60px" align="right">
                        <span class="label">创建时间</span>
                    </td>
                    <td>
                        <%-- 替换input为datebox--%>
                        <input type="text" class="easyui-datebox" style="width: 120px" id="CreateDateStart" />
                        <%--<input type="text" class="input-text" id="CreateDateStart" />--%>
                    </td>
                </tr>
                <tr>
                    <td style="width: 60px" align="right">
                        <span class="label">到</span>
                    </td>
                    <td>
                        <%-- 替换input为datebox--%>
                        <input type="text" class="easyui-datebox" style="width: 120px" id="CreateDateEnd"  />
                        <%--<input type="text" class="input-text" id="CreateDateEnd" />--%>
                    </td>
                </tr>
                <tr>
                    <td style="width: 60px" align="right">
                        <span class="label">公司编码</span>
                    </td>
                    <td>
                        <input type="text" class="input-text" id="Code" />
                    </td>
                </tr>
                <tr>
                    <td style="width: 60px" align="right">
                        <span class="label">公司名称</span>
                    </td>
                    <td>
                        <input type="text" class="input-text" id="Short" />
                    </td>
                </tr>
            </table>
        </div>
    </div>
    <div id="center-panel">
        <table id="listgrid"></table>
    </div>
    <div id="south-panel">
        <table style="margin-top: 5px; margin-left: 20px;">
            <tr>
                <td>
                    <input id="button-search" type="button" class="btnCss" value="搜    索" />
                    <input id="button-clear" type="button" class="btnCss" value="清    空" style="margin-left: 20px;" />
                    <input id="button-load" type="button" class="btnCss" value="导    出" style="margin-left: 20px;" />
                </td>
            </tr>
        </table>
    </div>
</body>
</html>
